package com.xinfan.io.outputstream;


import com.xinfan.io.Dog;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/**
 * @Author xin
 * @Date 2022/6/8 22:17
 * @Version 1.0
 */
public class ObjectOutputStream_ {
    public static void main(String[] args) throws IOException {

        String des = "G:\\桌面\\test.dat";

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(des));
        oos.writeInt(12);
        oos.writeDouble(9.9);
        oos.writeChar('中');
        oos.writeUTF("写入字符串的方法为UTF");

        Dog dog = new Dog("小黄", 2);
        dog = new Dog("ss",2);
        System.out.println(dog);
        oos.writeObject(dog);
        oos.close();

    }
}


